package std

import "encoding/json"

type Resp struct {
	Code int      `json:"code"`
	Msg  string   `json:"msg"`
	Data RespData `json:"data"`
}

func (r Resp) String() string {
	marshal, _ := json.Marshal(&r)
	return string(marshal)
}

type RespData struct {
	Data  any `json:"data"`
	Other any `json:"other"`
}

func NewResp(code int, msg string, data any, other any) Resp {
	return Resp{
		Code: code,
		Msg:  msg,
		Data: RespData{
			Data:  data,
			Other: other,
		},
	}
}

type ListParams struct {
	ID   uint `json:"id"`
	Page int  `json:"page" validate:"required,min=1"`
	Size int  `json:"size" validate:"required,min=1,max=10000"`
}
